﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Battleship
{
    public class Navigation
    {
        public int minTier;
        public int maxTier;
        public int minBay;
        public int maxBay;
        public int minRow;
        public int maxRow;
        public SlotPoint cursor;
        public Navigation()
        {
            minTier = 0;
            maxTier = 4;

            minBay = 0;
            maxBay = 7;

            minRow = 0;
            maxRow = 3;

            cursor = new SlotPoint(minTier, minBay, minRow);
        }
        public Navigation(int minT, int maxT, int minB, int maxB, int minR, int maxR)
        {
            minTier = minT;
            maxTier = maxT;

            minBay = minB;
            maxBay = maxB;

            minRow = minR;
            maxRow = maxR;

            cursor = new SlotPoint(minTier, minBay, minRow);
        }
        public bool Next()
        {
            bool result = true;
            if ((cursor.row + 1) > maxRow)
            {
                cursor.row = minRow;
                if ((cursor.bay + 1) > maxBay)
                {
                    cursor.bay = minBay;
                    if ((cursor.tier + 1) > maxTier)
                    {
                        result = false;
                    }
                    else
                    {
                        cursor.tier++;
                    }
                }
                else
                {
                    cursor.bay++;
                }
            }
            else
            {
                cursor.row++;
            }
            return result;
        }
        public bool Next(int bayStep)
        {
            bool result = true;
            if ((cursor.row + 1) > maxRow)
            {
                cursor.row = minRow;
                if ((cursor.bay + bayStep) > maxBay)
                {
                    cursor.bay = minBay;
                    if ((cursor.tier + 1) > maxTier)
                    {
                        result = false;
                    }
                    else
                    {
                        cursor.tier++;
                    }
                }
                else
                {
                    cursor.bay = cursor.bay + bayStep;
                }
            }
            else
            {
                cursor.row++;
            }
            return result;
        }
    }
}
